<template>
    <div class="answerItem" @click="goDetail(item)">
        <div class="title">
            {{ item.title }}
        </div>
        <div class="line"></div>
    </div>
</template>

<script>
export default {
    name: "answerItem",
    props: {
        item: {
            type: Object,
            default: () => {
                return {};
            },
        },
        showMoney: {
            type: Boolean,
            default: () => {
                return true;
            },
        },
    },
    data() {
        return {
            getAvatar: (str) => {
                if (typeof str == "string")
                    return JSON.parse(str).extendedData.avatar;
                else return str.extendedData.avatar;
            },
            getNickname: (str) => {
                if (typeof str == "string")
                    return JSON.parse(str).extendedData.nickname;
                else return str.extendedData.nickname;
            },
            getMessage: (str) => {
                if (typeof str == "string") {
                    let obj = JSON.parse(str);
                    if (obj.extendedData.type == 11) return "[图片]";
                    else return obj.message;
                } else
                    return str.extendedData.type == 11 ? "[图片]" : str.message;
            },
        };
    },
    methods: {
        goDetail(item) {
            if (item.status == 3) {
                let { href } = this.$router.resolve({
                    path: "/cswd/"+item.id+'.html',
                });
             
                window.open(href, "_blank");
            } else {
                this.$emit("goDetail", item);
            }
        },
    },
};
</script>

<style lang="scss" scoped>
.answerItem {
    padding: 0 23px;
    padding-top: 22px;
    cursor: pointer;
    &:hover {
        background-color: #f7f9fb;
    }
}

.title {
    font-size: 16px;
    color: #333333;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-bottom: 20px;
}

.info {
    padding: 0 0 19px;
    box-sizing: border-box;
    display: flex;
    align-items: center;

    .avatar {
        object-fit: cover;
        width: 50px;
        min-width: 50px;
        height: 50px;
        border-radius: 50px;
    }

    .right {
        box-sizing: border-box;
        padding-left: 14px;
        width: 100%;
        .top {
            display: flex;
            justify-content: space-between;
            color: #999999;
            font-size: 14px;
        }
        .bottom {
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            overflow: hidden;
            font-size: 14px;
            color: #333333;
            padding-top: 6px;
        }
    }
}
.line {
    height: 1px;
    width: 100%;
    background-color: #eeeeee;
}
</style>
